package com.ruoyi.system.service.impl;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.system.domain.DouyinUser;
import com.ruoyi.system.mapper.DouyinUserMapper;
import com.ruoyi.system.service.DouyinUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DouyinUserServiceImp implements DouyinUserService {
    @Autowired
    private DouyinUserMapper douyinUserMapper;

    @Override
    public void bindUser(DouyinUser douyinUser) {
        douyinUserMapper.bindUser(douyinUser);
    }

    @Override
    public Boolean isBind(Long userId) {
        return douyinUserMapper.isBind(userId) == 0;
    }

    /**
     * 获取指定用户的全书授权账号
     *
     * @return
     */
    @Override
    public List<DouyinUser> getDouyinUserByUserId(Long userId) {
        return douyinUserMapper.getOpenId(userId);
    }

    /**
     * 获取指定用户的全书授权账号
     *
     * @return
     */
    @Override
    public AjaxResult bindUsers(Long userId) {
        List<DouyinUser> douyinUserByUserId = this.getDouyinUserByUserId(userId);
        return AjaxResult.success("success", douyinUserByUserId);
    }

    @Override
    public Boolean isBindByOpenId(String openId) {
        return douyinUserMapper.isBindByOpenId(openId) == 0;
    }

    /**
     * 全部的用户列表
     *
     * @return
     */
    @Override
    public List<DouyinUser> getAllUser() {
        return douyinUserMapper.getAllUser();
    }

    @Override
    public DouyinUser findUserById(String id) {
        return douyinUserMapper.findUserById(id);
    }

    @Override
    public List<DouyinUser> getDouyinUserList() {
        return douyinUserMapper.getDouyinUserList();
    }

    @Override
    public List<DouyinUser> getDouyinUserListDESC() {
        return douyinUserMapper.getDouyinUserListDESC();
    }
}
